<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<link href="assets/css/bootstrap-select.css" rel="stylesheet"/>
<link href="assets/css/modify.css" rel="stylesheet"/>
<script src="assets/js/select2/select2.js"></script>
<style>
    .bootbox-close-button {
        width: 19px;
        height: 19px;
        border: none;
        cursor: pointer;
        -webkit-appearance: none;
        float: right;
        top: 4px;
        left: -5px;
        position: relative;
        background: #E9F5FF url("assets/img/nav-img/icon_close.png") no-repeat 0 0;
    }
    .bootbox .modal-dialog {
        width: 70% !important;
    }

    .modal-content {
        width: 100%;
    }
</style>
<div class="row  myDialogDetai2 myDialogDetai" style="margin-left:0px!important;">
    <!-- 映射列表 -->
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="leftTree">
        <div class="row" style="margin-bottom: 10px;margin-top:10px;font-size: 14px">
            <span style="padding-left: 16px;line-height: 30px">课时包信息</span>
            <label class="nomargin-bottom pull-right">
                <a type="btn" class="btn basicInfoBtnt" onclick="associationClassPackage()" style="background-color: #23a8f5;border: none;border-radius: 4px!important;width: 120px;color: #fff;margin-right: 0!important;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
                    关联课时包
                </a>
            </label>
        </div>
        <div class="widget flat radius-bordered" style="margin-top: 0;box-shadow:0px 0px 10px rgba(122,161,184,0.3);">
            <div class="widget-body no-padding">
                <div class="table-scrollable" style="border: none;">
                    <!-- 数据表列信息列表 -->
                    <table class="table table-hover dataTable newtable">
                        <input type="hidden" name="memberType" class="memberType" value="${memberType}">
                        <thead>
                        <tr>
                            <th title="序号">序号</th>
                            <th title="课时包名称">课时包名称</th>
                            <th title="合同编号">合同编号</th>
                            <th title="原单价">原单价</th>
                            <th title="折后价">折后价</th>
                            <th title="购买日期">购买日期</th>
                            <th title="是否共享">是否共享</th>
                            <th title="总课时数">总课时数</th>
                            <th title="赠课课时">赠课课时</th>
                            <th title="剩余课时">剩余课时</th>
                            <th title="已选班课时">已选班课时</th>
                            <th title="已消耗课时">已消耗课时</th>
                            <th title="可补课课时">可补课课时</th>
                            <th title="剩余有效期">剩余有效期</th>
                            <th title="使用状态">使用状态</th>
                            <th title="操作人">操作人</th>
                            <th title="最后操作日期">最后操作日期</th>
                            <th title="操作">操作</th>
                            <th title="备注信息">备注信息</th>
                        </tr>
                        </thead>
                        <tbody>

                        <#if memberPackagesList?size==0>
                            <tr>
                                <td align="center">无数据</td>
                            </tr>
                        </#if>
                        <#list memberPackagesList as data>
                            <tr>
                                <td>${data_index+1}</td>
                                <td>${(data.name???string(data.name?html,"未设置"))!'未设置'}</td>
                                <td>${(data.contractNumber???string(data.contractNumber?html,"未设置"))!'未设置'}</td>
                                <td>${(data.originalUnitPrice???string(data.originalUnitPrice?html,"未设置"))!'未设置'}</td>
                                <td>${(data.nowUnitPrice???string(data.nowUnitPrice?html,"未设置"))!'未设置'}</td>
                                <td>${(data.createTime???string(data.createTime?html,"未设置"))!'未设置'}</td>
                                <td>${(data.isShare???string(data.isShare?html,"未设置"))!'未设置'}</td>
                                <td>${(data.usableTotalClassHour???string(data.usableTotalClassHour?html,"未设置"))!'未设置'}</td>
                                <td>${(data.presentClassHour???string(data.presentClassHour?html,"未设置"))!'未设置'}</td>
                                <td>${(data.surplusClassHour???string(data.surplusClassHour?html,"未设置"))!'未设置'}</td>
                                <td>${(data.selectedClassHour???string(data.selectedClassHour?html,"未设置"))!'未设置'}</td>
                                <td>${(data.positiveConsumptionClassHour???string(data.positiveConsumptionClassHour?html,"未设置"))!'未设置'}+${(data.giftConsumptionClassHour???string(data.giftConsumptionClassHour?html,"未设置"))!'未设置'}</td>
                                <td>${(data.remediationClassHour???string(data.remediationClassHour?html,"未设置"))!'未设置'}</td>
                                <td>${(data.surplusValidDate???string(data.surplusValidDate?html,"未设置"))!'未设置'}</td>
                                <td><@dictionary groupCode="packageStatus" dictionaryCode="${data.packageStatus}" ;packageStatus>${packageStatus.value }</@dictionary></td>
                                <td>${(data.userName???string(data.userName?html,"未设置"))!'未设置'}</td>
                                <td>${(data.createTime???string(data.createTime?html,"未设置"))!'未设置'}</td>
                                <td>
                                    <#if  data.packageStatus==2 >
                                        <@hp code="HYGL22644030125229-activate_package"
                                        params="[targetDataId=${data.id}]"/>
                                    </#if>
                                    <#if  data.isShare==0 >
                                        <@hp code="HYGL22644030125229-permit_share"
                                        params="[targetDataId=${data.id}]"/>
                                    </#if>
                                    <#if  data.isShare==1 >
                                        <a  onclick="changePakcageIsShare(this)" targetDataId="${data.id}" >取消关联</a>
                                    </#if>
                                </td>
                                <td>${(data.remark???string(data.remark?html,"未设置"))!'未设置'}</td>
                            </tr>
                        </#list>
                        </tbody>

                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(".selectpicker").select2();

//    关联课时包
    function associationClassPackage() {
        ajaxRequest("tssMemberPackageController/associationClassPackage.do",{

        }, function (html) {
            getTopWin().bootbox.dialog({
                message: html,
                title: "关联课时包",
                className: 'myDialog associationClassPackageDialog',
            });
            $(".modal-header").find(".bootbox-close-button").removeClass("close");
            $(".modal-header").find(".bootbox-close-button").html("");
        }, function () {
            ajaxError("加载页面失败!")
        }, "get", "html")
    }

    function changePakcageStauts(that){
        var targetdataId = $(that).attr("targetDataId");
        ajaxRequest("tssMemberPackageController/updatePackageStatus.do",{
            targetDateId:targetdataId,
            packageStatus:2
        }, function (result) {
            alert("激活成功");
            if (result.resCode == 200) {
                bootbox.hideAll();
            }
        },function(){
            ajaxError("加载员工信息失败");
        }, "post","json")

    }
</script>
